<%--
  Created by IntelliJ IDEA.
  User: xw
  Date: 2018/5/4
  Time: 10:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!--/sidebar-menu-->
<div class="sidebar-menu">
    <header class="logo1">
        <a href="#" class="sidebar-icon"> <span class="fa fa-bars"></span> </a>
    </header>
    <div style="border-top:1px ridge rgba(255, 255, 255, 0.15)"></div>
    <div class="menu">
        <ul id="menu" >
            <li id="menu-academico1">
                <a href="/api/adminUsers/toAdminIndex"><i class="fa fa-tachometer"></i> <span>系统首页</span><div class="clearfix"></div></a>
            </li>
            <li id="menu-academico2" >
                <a href="/api/adminUsers/toUserManage"><i class="fa fa-user"></i><span>用户管理</span><div class="clearfix"></div></a>
            </li>
            <li id="menu-academico3" >
                <a href="/api/adminUsers/toStudentManage"><i class="fa fa-user"></i><span>学生管理</span><div class="clearfix"></div></a>
            </li>
            <li id="menu-academico4">
                <a type="button" id="showModal1" onclick="showmodal()" data-toggle="modal" data-target="#updateUserModal">
                    <i class="fa fa-cog" aria-hidden="true" ></i><span>个人中心</span><div class="clearfix"></div>
                </a>
            </li>
        </ul>
    </div>
</div>
<div class="clearfix"></div>
<script>
    function showmodal(){
        $('#identifier').modal('show');
    }
</script>
<!-- 模态框（Modal） -->
<div class="modal fade" id="updateUserModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabelAdd">
                    修改个人信息
                </h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" id="updateUserInfoForm">
                    <div class="form-group">
                        <label for="userName" class="col-sm-2 control-label hor-form">用户名</label>
                        <div class="col-sm-10">
                            <input type="text" name="userName" class="form-control" id="userName" value="${sessionScope.currentUser.userName}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="password" class="col-sm-2 control-label hor-form">密码</label>
                        <div class="col-sm-10">
                            <input type="password" name="password" class="form-control" id="password" placeholder="密码默认不修改">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="idCardName" class="col-sm-2 control-label hor-form">姓名</label>
                        <div class="col-sm-10">
                            <input type="text" name="idCardName" class="form-control" id="idCardName" value="${sessionScope.currentUser.idCardName}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="idCard" class="col-sm-2 control-label hor-form">身份证号</label>
                        <div class="col-sm-10">
                            <input type="text" name="idCard" class="form-control" id="idCard" value="${sessionScope.currentUser.idCard}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="userPhone" class="col-sm-2 control-label hor-form">电话</label>
                        <div class="col-sm-10">
                            <input type="text" name="userPhone" class="form-control" id="userPhone" value="${sessionScope.currentUser.userPhone}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="email" class="col-sm-2 control-label hor-form">邮箱</label>
                        <div class="col-sm-10">
                            <input type="text" name="email" class="form-control" id="email" value="${sessionScope.currentUser.email}">
                        </div>
                    </div>
                    <!-- 待完善其他属性修改:用户角色暂时无法修改-->
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">
                    取消
                </button>
                <button type="button" class="btn btn-primary" id="updateUserInfoButton">
                    修改
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div>
</div><!-- /.modal -->
<script>
    $(function(){
        $("#updateUserInfoButton").click(
            function() {
                $.ajax({
                    url: '/api/adminUsers/updateAdminUsersInfo',
                    type: 'post',
                    dataType: 'json',
                    data:$('#updateUserInfoForm').serialize(),
                    success: function (data) {
                        if (data.status == 0) {
                            alert(data.msg);
                            $('#identifier').modal('hide');
                        } else {
                            alert(data.msg);
                        }
                    },
                    error : function(data) {
                        alert(data.msg);
                    },
                });
            }
        );
    });
</script>